package com.hsc.yalebao.merchant.activity;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;

import com.dinpay.plugin.activity.DinpayChannelActivity;
import com.hsc.yalebao.merchant.model.OrderInfo;
import com.itrus.util.sign.RSAWithHardware;
import com.itrus.util.sign.RSAWithSoftware;

import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class PayUtils {
    private static String UserKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALX6gE8//X7VPThwaHy94dCy1bgd2fhG8iX35EoKHp5adYqgDbYao1HbNjLW5yUrJb+WwimaRHBQwKYpj6vunSdHTdTCFNprEtmihOxZmQkQm2OPE9jcTA2PEvLDmt7AwHsZoV1MUuo2tfmIZ1v2NqmJ8wJqqdpPiEoBV40RWLFBAgMBAAECgYANYNch/GBUfLS9e3YTBZqeTydrG7a0i/KtW+YKk2fg2GGfyVh4tMig8e6wGiBwGRXzWc/4YwD5CNbA4HlReH9RDi6Ug7CCW+kBrXEFmn8FhuSpqd3s0ACpgeDBCq8zdzJ0C/jLN/Bca2V1TpFkGga5JIsHngyXPLoYYo1jt+RPgQJBANgzFWQFHCn4gCbtO6I55xxveeZXu9QEvKHmb8wrHDLgKIE45VFyUy/mUGXk3acsuPA1dm9h3+TpyfQxtt12g2kCQQDXequxiKx8OMOe8VM51fBv9r/C5g2glrl3M8uT2bOMmvg+rE+PJMuJNW2fjN9Bmu8LppWYOmntk7VB3mj/R3wZAkBEfCoSfOvm/6jYq91wDhd/knBy3ufIyZdXUb+oVR+hnhA2nudFXYmsarCdFlqAUlJjBQx3S/G4ebZXfEgI7znBAkEA1iusSZoR7qow7WLpmNumznJPqTUlqE8Hao6Fsp+4UXGaehikPx+QWgFLw0CuirOnE0pw98xfiu68QwsAC3OOyQJAHGvRKAQTFXB43pxvIC3Dd6/oCsJ2xulaodOohaPej4lzMyBsg5XEwaub/WjEXJA8S7lddKDskjaDyZKWkVyssg==";
    private static String merchant_code = "2010500324";
    private static String sign_type = "RSA-S";
    private Context context;

    private static String getRSASSignature(String paramString)
            throws Exception {
        if (UserKey.equals(""))
            return "";
        return RSAWithSoftware.signByPrivateKey(paramString, UserKey).replaceAll("\\+", "%2B");
    }

    private static String getRSASignature(String paramString)
            throws Exception {
        if ("".equals(""))
            return "";
        RSAWithHardware localRSAWithHardware = new RSAWithHardware();
        localRSAWithHardware.initSigner("", "");
        String str = localRSAWithHardware.signByPriKey(paramString);
        System.out.println("商家发送的签名：" + str.length() + " =>" + str);
        return str;
    }

    public static void pay(Context paramContext, String paramString1, String paramString2, String paramString3)
            throws Exception {
        OrderInfo localOrderInfo = new OrderInfo();
        localOrderInfo.setMerchant_code(merchant_code);
        localOrderInfo.setNotify_url(paramString2);
        localOrderInfo.setInterface_version("V3.0");
        localOrderInfo.setOrder_no(paramString1);
        localOrderInfo.setOrder_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        localOrderInfo.setOrder_amount(paramString3);
        localOrderInfo.setProduct_name("充值" + paramString3);
        Map localMap = localOrderInfo.getMap();
        StringBuffer localStringBuffer = new StringBuffer();
        Iterator localIterator = localMap.entrySet().iterator();
        while (true) {
            Object localObject = null;
            if (!localIterator.hasNext())
                localObject = localStringBuffer.toString().substring(0, -1 + localStringBuffer.toString().length());
            try {
                String str5;
                if (sign_type.equals("RSA-S"))
                    str5 = getRSASSignature((String) localObject);
                String str4;
                for (localObject = str5; ; localObject = str4) {
                    String str2 = ((String) localObject).replaceAll("\\+", "%2B");
                    String str3 = "<?xml version=\"1.0\" encoding=\"utf-8\"?><dinpay><request><merchant_code>" + localOrderInfo.getMerchant_code() + "</merchant_code>" + "<notify_url>" + localOrderInfo.getNotify_url() + "</notify_url>" + "<interface_version>" + localOrderInfo.getInterface_version() + "</interface_version>" + "<sign_type>" + sign_type + "</sign_type>" + "<sign>" + str2 + "</sign>" + "<trade><order_no>" + localOrderInfo.getOrder_no() + "</order_no>" + "<order_time>" + localOrderInfo.getOrder_time() + "</order_time>" + "<order_amount>" + localOrderInfo.getOrder_amount() + "</order_amount>" + "<product_name>" + localOrderInfo.getProduct_name() + "</product_name>" + "<redo_flag>" + localOrderInfo.getRedo_flag() + "</redo_flag>" + "<product_code>" + localOrderInfo.getProduct_code() + "</product_code>" + "<product_num>" + localOrderInfo.getProduct_num() + "</product_num>" + "<product_desc>" + localOrderInfo.getProduct_desc() + "</product_desc>" + "<extra_return_param>" + localOrderInfo.getExtra_return_param() + "</extra_return_param>" + "</trade></request></dinpay>";
                    Log.i("xml=", str3);
                    Intent localIntent = new Intent(paramContext, DinpayChannelActivity.class);
                    localIntent.putExtra("xml", str3);
                    localIntent.putExtra("ActivityName", "com.hsc.yalebao.merchant.activity.MerchantPayResultActivity");
                    paramContext.startActivity(localIntent);
                    return;
                    Map.Entry localEntry = (Map.Entry) localIterator.next();
                    String str1 = (String) localEntry.getValue();
                    if (TextUtils.isEmpty(str1))
                        break;
                    localStringBuffer.append((String) localEntry.getKey() + "=" + str1 + "&");
                    break;
                    str4 = getRSASignature((String) localObject);
                }
            } catch (Exception localException) {
                while (true)
                    localException.printStackTrace();
            }
        }
    }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.merchant.activity.PayUtils
 * JD-Core Version:    0.6.2
 */